package com.travelparadise.tests;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

import junit.framework.TestCase;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import com.travelparadise.dao.ActiviteDao;
import com.travelparadise.domain.Activite;
import com.travelparadise.domain.Ville;

public class TestActiviteDao extends TestCase {
	private ActiviteDao activiteDao = null;
	
	private Logger logger = Logger.getLogger("TestActiviteDao");

	@Override
	protected void setUp() throws Exception {
		ApplicationContext springContext = SpringContextForTest.getSpringContext();
		this.activiteDao = (ActiviteDao) springContext.getBean("activiteDaoHibernate");
	}
		
	public void testGetById(){
		Activite activite = activiteDao.getById(1);
		System.out.println(activite.getNom()+" "+activite.getPrix());
		System.out.println("*****************************************");
		assertTrue(activite.getId()==1);
	}
	
	public void testsearchByPrice(){
		Collection<Activite> activites = activiteDao.searchByPrice(0, 10);
		for(Activite activite : activites){
			System.out.println(activite.getNom()+" "+activite.getPrix());
		}
		System.out.println("*****************************************");
	}
	
	public void testSearchByVille(){
		Ville v = new Ville();
		v.setId(6);
		
		Collection<Activite> activites = activiteDao.getActivitesInVille(v);		
		for(Activite activite : activites){
			System.out.println(activite.getNom()+" "+activite.getPrix());
		}
		System.out.println("*****************************************");
	}
	
	public void testSearchByName(){	
		Collection<Activite> activites = activiteDao.searchByName("tennis");	
		
		for(Activite activite : activites){
			logger.info(activite.getNom()+" "+activite.getPrix());
		}		
	}
}
